<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>
    //第一题
    let y = []
    for (let i = 0; i < 26; i++) {
        y.push(String.fromCharCode(65 + i));
        y.push(String.fromCharCode(97 + i));
    }
    console.log(y);

    //第二题
    let arr2 = prompt('输入字符')
    let newarr2 = arr2.split('').reverse().join('')
    alert(newarr2);

    //第三题
    let arr3 = ['t', 'o', 'm', 'o', 'r', 'r', 'o', 'w'];
    let att = arr3.join(',');
    console.log(att.replace(/o/g, 'a').split(','));
    //let sttarr = 'tomorrow'.spilt('')
    // let newarr = []
    // strarr.map(function(item){
    //     if(item == '0'){
    //         newarr.push('a')
    //     }else{
    //         newstrarr.push(item)
    //     }
    //    })

    //第四题
    let arr4 = prompt('请输入你要查询的单词')
    if (arr4 == arr4.split('').reverse().join('')) {
        alert(`你输入的为回文符`)
    } else {
        alert(`你输入的不是回文符`)
    }

    //第五题
    let arr5 = [];
    let sum = 0
    for (let i = 0; i < 20; i++) {
        let arr5Num = parseInt(Math.random(0) * (100 - 0 + 1) + 0);
        let flag = true;
        for (let j = 0; j <= arr5.length; j++) {
            if (arr5Num == arr5[j]) {
                flag = false;
                break;
            }
        }
        if (flag = true) {
            arr5.push(arr5Num);
        } else {
            i--;
        }
    }
    console.log(arr5)
    let max = arr5[0];
    for (let i = 0; i < arr5.length - 1; i++) {
        max = max < arr5[i + 1] ? arr5[i + 1] : max
    }
    console.log('最大值为', max);
    let mid = arr5[0];
    for (let i = 0; i < arr5.length - 1; i++) {
        mid = mid > arr5[i + 1] ? arr5[i + 1] : mid
    }
    console.log('最小值为', mid);

    for (let i = 0; i < arr5.length; i++) {
        sum += arr5[i];
    }
    let sum1 = sum / arr5.length
    console.log('数组和为', sum);
    console.log('数组平均值为', sum1);
    let cha = [];
    for (let i = 0; i < arr5.length; i++) {
        let cha1 = Math.round(arr5[i] - sum1);
        cha.push(cha1)
    }
    console.log(cha);
    let sheng = cha.sort(function (a1, a2) {
        return a1 - a2;
    });
    console.log(sheng);

    //第六题
    let arr6 = [1, 2, 2, 3, 3, 5, 76, 76, 4, 4, 3, 2, 2]
    let arr6back = arr6.reduce((pre, cur) => {
        if (!pre.includes(cur)) {//如果该元素再新数组中不存在
            return pre.concat(cur) //将该元素添加到新数组中
        } else {
            return pre
        }
    }, [])
    console.log(arr6back);// [1, 2, 3, 4]
</script>